(0) Obligation:

Clauses:

sum([], [], []).
sum(.(X1, Y1), .(X2, Y2), .(X3, Y3)) :- ','(add(X1, X2, X3), sum(Y1, Y2, Y3)).
add(0, X, X).
add(s(X), Y, s(Z)) :- add(X, Y, Z).

Query: sum(g,a,g)

(1) PrologToPrologProblemTransformerProof (SOUND transformation)

Built Prolog problem from termination graph ICLP10.

(2) Obligation:

Clauses:

pA(0, T22, T22, T11, T23, T15) :- sumB(T11, T23, T15).
pA(s(T30), T33, s(T32), T11, T34, T15) :- pA(T30, T33, T32, T11, T34, T15).
sumB([], [], []).
sumB(.(T10, T11), .(T16, T17), .(T14, T15)) :- pA(T10, T16, T14, T11, T17, T15).

Query: sumB(g,a,g)

(3) PrologToPiTRSProof (SOUND transformation)

We use the technique of [TOCL09]. With regard to the inferred argument filtering the predicates were used in the following modes:
sumB_in: (b,f,b)
pA_in: (b,f,b,b,f,b)
Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

sumB_in_gag([], [], []) → sumB_out_gag([], [], [])
sumB_in_gag(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_gag(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
pA_in_gaggag(0, T22, T22, T11, T23, T15) → U1_gaggag(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
U1_gaggag(T22, T11, T23, T15, sumB_out_gag(T11, T23, T15)) → pA_out_gaggag(0, T22, T22, T11, T23, T15)
pA_in_gaggag(s(T30), T33, s(T32), T11, T34, T15) → U2_gaggag(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
U2_gaggag(T30, T33, T32, T11, T34, T15, pA_out_gaggag(T30, T33, T32, T11, T34, T15)) → pA_out_gaggag(s(T30), T33, s(T32), T11, T34, T15)
U3_gag(T10, T11, T16, T17, T14, T15, pA_out_gaggag(T10, T16, T14, T11, T17, T15)) → sumB_out_gag(.(T10, T11), .(T16, T17), .(T14, T15))

The argument filtering Pi contains the following mapping:
sumB_in_gag(x1, x2, x3)  =  sumB_in_gag(x1, x3)
[]  =  []
sumB_out_gag(x1, x2, x3)  =  sumB_out_gag(x2)
.(x1, x2)  =  .(x1, x2)
U3_gag(x1, x2, x3, x4, x5, x6, x7)  =  U3_gag(x7)
pA_in_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_in_gaggag(x1, x3, x4, x6)
0  =  0
U1_gaggag(x1, x2, x3, x4, x5)  =  U1_gaggag(x1, x5)
pA_out_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_out_gaggag(x2, x5)
s(x1)  =  s(x1)
U2_gaggag(x1, x2, x3, x4, x5, x6, x7)  =  U2_gaggag(x7)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog

(4) Obligation:

Pi-finite rewrite system:
The TRS R consists of the following rules:

sumB_in_gag([], [], []) → sumB_out_gag([], [], [])
sumB_in_gag(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_gag(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
pA_in_gaggag(0, T22, T22, T11, T23, T15) → U1_gaggag(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
U1_gaggag(T22, T11, T23, T15, sumB_out_gag(T11, T23, T15)) → pA_out_gaggag(0, T22, T22, T11, T23, T15)
pA_in_gaggag(s(T30), T33, s(T32), T11, T34, T15) → U2_gaggag(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
U2_gaggag(T30, T33, T32, T11, T34, T15, pA_out_gaggag(T30, T33, T32, T11, T34, T15)) → pA_out_gaggag(s(T30), T33, s(T32), T11, T34, T15)
U3_gag(T10, T11, T16, T17, T14, T15, pA_out_gaggag(T10, T16, T14, T11, T17, T15)) → sumB_out_gag(.(T10, T11), .(T16, T17), .(T14, T15))

The argument filtering Pi contains the following mapping:
sumB_in_gag(x1, x2, x3)  =  sumB_in_gag(x1, x3)
[]  =  []
sumB_out_gag(x1, x2, x3)  =  sumB_out_gag(x2)
.(x1, x2)  =  .(x1, x2)
U3_gag(x1, x2, x3, x4, x5, x6, x7)  =  U3_gag(x7)
pA_in_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_in_gaggag(x1, x3, x4, x6)
0  =  0
U1_gaggag(x1, x2, x3, x4, x5)  =  U1_gaggag(x1, x5)
pA_out_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_out_gaggag(x2, x5)
s(x1)  =  s(x1)
U2_gaggag(x1, x2, x3, x4, x5, x6, x7)  =  U2_gaggag(x7)

(5) DependencyPairsProof (EQUIVALENT transformation)

Using Dependency Pairs [AG00,LOPSTR] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_GAG(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → PA_IN_GAGGAG(T10, T16, T14, T11, T17, T15)
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → U1_GAGGAG(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → SUMB_IN_GAG(T11, T23, T15)
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → U2_GAGGAG(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → PA_IN_GAGGAG(T30, T33, T32, T11, T34, T15)

The TRS R consists of the following rules:

sumB_in_gag([], [], []) → sumB_out_gag([], [], [])
sumB_in_gag(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_gag(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
pA_in_gaggag(0, T22, T22, T11, T23, T15) → U1_gaggag(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
U1_gaggag(T22, T11, T23, T15, sumB_out_gag(T11, T23, T15)) → pA_out_gaggag(0, T22, T22, T11, T23, T15)
pA_in_gaggag(s(T30), T33, s(T32), T11, T34, T15) → U2_gaggag(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
U2_gaggag(T30, T33, T32, T11, T34, T15, pA_out_gaggag(T30, T33, T32, T11, T34, T15)) → pA_out_gaggag(s(T30), T33, s(T32), T11, T34, T15)
U3_gag(T10, T11, T16, T17, T14, T15, pA_out_gaggag(T10, T16, T14, T11, T17, T15)) → sumB_out_gag(.(T10, T11), .(T16, T17), .(T14, T15))

The argument filtering Pi contains the following mapping:
sumB_in_gag(x1, x2, x3)  =  sumB_in_gag(x1, x3)
[]  =  []
sumB_out_gag(x1, x2, x3)  =  sumB_out_gag(x2)
.(x1, x2)  =  .(x1, x2)
U3_gag(x1, x2, x3, x4, x5, x6, x7)  =  U3_gag(x7)
pA_in_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_in_gaggag(x1, x3, x4, x6)
0  =  0
U1_gaggag(x1, x2, x3, x4, x5)  =  U1_gaggag(x1, x5)
pA_out_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_out_gaggag(x2, x5)
s(x1)  =  s(x1)
U2_gaggag(x1, x2, x3, x4, x5, x6, x7)  =  U2_gaggag(x7)
SUMB_IN_GAG(x1, x2, x3)  =  SUMB_IN_GAG(x1, x3)
U3_GAG(x1, x2, x3, x4, x5, x6, x7)  =  U3_GAG(x7)
PA_IN_GAGGAG(x1, x2, x3, x4, x5, x6)  =  PA_IN_GAGGAG(x1, x3, x4, x6)
U1_GAGGAG(x1, x2, x3, x4, x5)  =  U1_GAGGAG(x1, x5)
U2_GAGGAG(x1, x2, x3, x4, x5, x6, x7)  =  U2_GAGGAG(x7)

We have to consider all (P,R,Pi)-chains

(6) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_GAG(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → PA_IN_GAGGAG(T10, T16, T14, T11, T17, T15)
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → U1_GAGGAG(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → SUMB_IN_GAG(T11, T23, T15)
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → U2_GAGGAG(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → PA_IN_GAGGAG(T30, T33, T32, T11, T34, T15)

The TRS R consists of the following rules:

sumB_in_gag([], [], []) → sumB_out_gag([], [], [])
sumB_in_gag(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_gag(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
pA_in_gaggag(0, T22, T22, T11, T23, T15) → U1_gaggag(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
U1_gaggag(T22, T11, T23, T15, sumB_out_gag(T11, T23, T15)) → pA_out_gaggag(0, T22, T22, T11, T23, T15)
pA_in_gaggag(s(T30), T33, s(T32), T11, T34, T15) → U2_gaggag(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
U2_gaggag(T30, T33, T32, T11, T34, T15, pA_out_gaggag(T30, T33, T32, T11, T34, T15)) → pA_out_gaggag(s(T30), T33, s(T32), T11, T34, T15)
U3_gag(T10, T11, T16, T17, T14, T15, pA_out_gaggag(T10, T16, T14, T11, T17, T15)) → sumB_out_gag(.(T10, T11), .(T16, T17), .(T14, T15))

The argument filtering Pi contains the following mapping:
sumB_in_gag(x1, x2, x3)  =  sumB_in_gag(x1, x3)
[]  =  []
sumB_out_gag(x1, x2, x3)  =  sumB_out_gag(x2)
.(x1, x2)  =  .(x1, x2)
U3_gag(x1, x2, x3, x4, x5, x6, x7)  =  U3_gag(x7)
pA_in_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_in_gaggag(x1, x3, x4, x6)
0  =  0
U1_gaggag(x1, x2, x3, x4, x5)  =  U1_gaggag(x1, x5)
pA_out_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_out_gaggag(x2, x5)
s(x1)  =  s(x1)
U2_gaggag(x1, x2, x3, x4, x5, x6, x7)  =  U2_gaggag(x7)
SUMB_IN_GAG(x1, x2, x3)  =  SUMB_IN_GAG(x1, x3)
U3_GAG(x1, x2, x3, x4, x5, x6, x7)  =  U3_GAG(x7)
PA_IN_GAGGAG(x1, x2, x3, x4, x5, x6)  =  PA_IN_GAGGAG(x1, x3, x4, x6)
U1_GAGGAG(x1, x2, x3, x4, x5)  =  U1_GAGGAG(x1, x5)
U2_GAGGAG(x1, x2, x3, x4, x5, x6, x7)  =  U2_GAGGAG(x7)

We have to consider all (P,R,Pi)-chains

(7) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LOPSTR] contains 1 SCC with 3 less nodes.

(8) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → PA_IN_GAGGAG(T10, T16, T14, T11, T17, T15)
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → SUMB_IN_GAG(T11, T23, T15)
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → PA_IN_GAGGAG(T30, T33, T32, T11, T34, T15)

The TRS R consists of the following rules:

sumB_in_gag([], [], []) → sumB_out_gag([], [], [])
sumB_in_gag(.(T10, T11), .(T16, T17), .(T14, T15)) → U3_gag(T10, T11, T16, T17, T14, T15, pA_in_gaggag(T10, T16, T14, T11, T17, T15))
pA_in_gaggag(0, T22, T22, T11, T23, T15) → U1_gaggag(T22, T11, T23, T15, sumB_in_gag(T11, T23, T15))
U1_gaggag(T22, T11, T23, T15, sumB_out_gag(T11, T23, T15)) → pA_out_gaggag(0, T22, T22, T11, T23, T15)
pA_in_gaggag(s(T30), T33, s(T32), T11, T34, T15) → U2_gaggag(T30, T33, T32, T11, T34, T15, pA_in_gaggag(T30, T33, T32, T11, T34, T15))
U2_gaggag(T30, T33, T32, T11, T34, T15, pA_out_gaggag(T30, T33, T32, T11, T34, T15)) → pA_out_gaggag(s(T30), T33, s(T32), T11, T34, T15)
U3_gag(T10, T11, T16, T17, T14, T15, pA_out_gaggag(T10, T16, T14, T11, T17, T15)) → sumB_out_gag(.(T10, T11), .(T16, T17), .(T14, T15))

The argument filtering Pi contains the following mapping:
sumB_in_gag(x1, x2, x3)  =  sumB_in_gag(x1, x3)
[]  =  []
sumB_out_gag(x1, x2, x3)  =  sumB_out_gag(x2)
.(x1, x2)  =  .(x1, x2)
U3_gag(x1, x2, x3, x4, x5, x6, x7)  =  U3_gag(x7)
pA_in_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_in_gaggag(x1, x3, x4, x6)
0  =  0
U1_gaggag(x1, x2, x3, x4, x5)  =  U1_gaggag(x1, x5)
pA_out_gaggag(x1, x2, x3, x4, x5, x6)  =  pA_out_gaggag(x2, x5)
s(x1)  =  s(x1)
U2_gaggag(x1, x2, x3, x4, x5, x6, x7)  =  U2_gaggag(x7)
SUMB_IN_GAG(x1, x2, x3)  =  SUMB_IN_GAG(x1, x3)
PA_IN_GAGGAG(x1, x2, x3, x4, x5, x6)  =  PA_IN_GAGGAG(x1, x3, x4, x6)

We have to consider all (P,R,Pi)-chains

(9) UsableRulesProof (EQUIVALENT transformation)

For (infinitary) constructor rewriting [LOPSTR] we can delete all non-usable rules from R.

(10) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

SUMB_IN_GAG(.(T10, T11), .(T16, T17), .(T14, T15)) → PA_IN_GAGGAG(T10, T16, T14, T11, T17, T15)
PA_IN_GAGGAG(0, T22, T22, T11, T23, T15) → SUMB_IN_GAG(T11, T23, T15)
PA_IN_GAGGAG(s(T30), T33, s(T32), T11, T34, T15) → PA_IN_GAGGAG(T30, T33, T32, T11, T34, T15)

R is empty.
The argument filtering Pi contains the following mapping:
.(x1, x2)  =  .(x1, x2)
0  =  0
s(x1)  =  s(x1)
SUMB_IN_GAG(x1, x2, x3)  =  SUMB_IN_GAG(x1, x3)
PA_IN_GAGGAG(x1, x2, x3, x4, x5, x6)  =  PA_IN_GAGGAG(x1, x3, x4, x6)

We have to consider all (P,R,Pi)-chains

(11) PiDPToQDPProof (SOUND transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(12) Obligation:

Q DP problem:
The TRS P consists of the following rules:

SUMB_IN_GAG(.(T10, T11), .(T14, T15)) → PA_IN_GAGGAG(T10, T14, T11, T15)
PA_IN_GAGGAG(0, T22, T11, T15) → SUMB_IN_GAG(T11, T15)
PA_IN_GAGGAG(s(T30), s(T32), T11, T15) → PA_IN_GAGGAG(T30, T32, T11, T15)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.

(13) QDPSizeChangeProof (EQUIVALENT transformation)

By using the subterm criterion [SUBTERM_CRITERION] together with the size-change analysis [AAECC05] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:

  • PA_IN_GAGGAG(0, T22, T11, T15) → SUMB_IN_GAG(T11, T15)
    The graph contains the following edges 3 >= 1, 4 >= 2

  • PA_IN_GAGGAG(s(T30), s(T32), T11, T15) → PA_IN_GAGGAG(T30, T32, T11, T15)
    The graph contains the following edges 1 > 1, 2 > 2, 3 >= 3, 4 >= 4

  • SUMB_IN_GAG(.(T10, T11), .(T14, T15)) → PA_IN_GAGGAG(T10, T14, T11, T15)
    The graph contains the following edges 1 > 1, 2 > 2, 1 > 3, 2 > 4

(14) YES